Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional sudo use in scripts (and README consistency) #362

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tyler-yankee
Copy link
Collaborator

@tyler-yankee tyler-yankee commented Jan 23, 2025

This addresses #359, and serves as a follow-up to #357.


This change is Reviewable

@tyler-yankee
Copy link
Collaborator Author

The one file that isn't converted to the new system here is drake_cmake_installed/setup/install_prereqs, because that script has conflicting/conditional logic of whether or not to use sudo based on the OS.

@tyler-yankee
Copy link
Collaborator Author

+@BetsyMcPhail for feature review, please

Copy link
Contributor

@BetsyMcPhail BetsyMcPhail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Linux portion of drake_cmake_installed/setup/install_prereqs, the same maybe_sudo logic should be applied.

Reviewed 17 of 18 files at r1, all commit messages.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee betsymcphail, platform LGTM missing (waiting on @tyler-yankee)


drake_bazel_external/.github/setup line 6 at r1 (raw file):

set -euxo pipefail

maybe_sudo=

All of the files in the .github subdirectories are only called by CI. We control the CI environment so don't need to do the maybe_sudo check.

@tyler-yankee tyler-yankee force-pushed the conditional-sudo branch 3 times, most recently from 0ef9f14 to c675165 Compare January 27, 2025 14:00
Copy link
Collaborator Author

@tyler-yankee tyler-yankee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Reviewable status: 1 unresolved discussion, LGTM missing from assignee betsymcphail, platform LGTM missing (waiting on @BetsyMcPhail)


drake_bazel_external/.github/setup line 6 at r1 (raw file):

Previously, BetsyMcPhail (Betsy McPhail) wrote…

All of the files in the .github subdirectories are only called by CI. We control the CI environment so don't need to do the maybe_sudo check.

Fixed.

Copy link
Contributor

@BetsyMcPhail BetsyMcPhail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 8 of 8 files at r2, all commit messages.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee betsymcphail, platform LGTM missing (waiting on @tyler-yankee)


drake_cmake_installed/setup/install_prereqs line 92 at r2 (raw file):

echo -e "\ndrake VERSION.TXT: $(cat /opt/drake/share/doc/drake/VERSION.TXT)\n"

/opt/drake/share/drake/setup/install_prereqs

When this is run locally, does this require sudo on Ubuntu?

Copy link
Contributor

@BetsyMcPhail BetsyMcPhail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee betsymcphail, platform LGTM missing (waiting on @tyler-yankee)


drake_cmake_installed/setup/install_prereqs line 92 at r2 (raw file):

Previously, BetsyMcPhail (Betsy McPhail) wrote…

When this is run locally, does this require sudo on Ubuntu?

I should have been more clear. I believe this will require sudo on Ubuntu but NOT on Mac. This PR needs a rebase after the /opt changes, which may make the changes in this file more clear.

@tyler-yankee
Copy link
Collaborator Author

drake_cmake_installed/setup/install_prereqs line 92 at r2 (raw file):

Previously, BetsyMcPhail (Betsy McPhail) wrote…

I should have been more clear. I believe this will require sudo on Ubuntu but NOT on Mac. This PR needs a rebase after the /opt changes, which may make the changes in this file more clear.

Sorry, forgot to hit "send" on my comment from earlier.

My changes should achieve this. ${maybe_sudo} is only assigned inside the Ubuntu case, so it won't expand to anything when running on Mac i.e. call without sudo.

I'll rebase this shortly so it's ready to go.

@tyler-yankee tyler-yankee force-pushed the conditional-sudo branch 2 times, most recently from 451b2af to c92e2b5 Compare January 27, 2025 21:13
Copy link
Contributor

@BetsyMcPhail BetsyMcPhail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 11 of 11 files at r4, all commit messages.
Reviewable status: :shipit: complete! all discussions resolved, platform LGTM from [betsymcphail] (waiting on @tyler-yankee)

Copy link
Contributor

@BetsyMcPhail BetsyMcPhail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+@jwnimmer-tri - would you prefer to platform review this or assign it to the on-call reviewer?

Reviewable status: all discussions resolved, LGTM missing from assignee jwnimmer-tri, platform LGTM from [betsymcphail] (waiting on @jwnimmer-tri)

Copy link
Contributor

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: modulo open discussions.

Reviewed 7 of 18 files at r1, 11 of 11 files at r4, all commit messages.
Reviewable status: 5 unresolved discussions, platform LGTM from [betsymcphail, jwnimmer-tri] (waiting on @tyler-yankee)


drake_cmake_installed/setup/install_prereqs line 6 at r4 (raw file):

# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without

BTW Yuck, I guess I missed this file in #361.

I just went back through the history of this file and the only non-relicenseable commit in its ancestry was #181, and I'll say it's been sufficiently rewritten since then that the commit is no longer relevant.

So either in this PR, or in a separate one, please delete this license text and replace with our standard SPDX MIT-0 line.


drake_cmake_installed/setup/install_prereqs line 41 at r4 (raw file):

      exit 1
    fi
    maybe_sudo= # assign empty for later call to install source prereqs

It seems to me like assigning the empty string should happen prior to the case ... beginning, since we need it to be defined no matter which branch was taken.


drake_cmake_installed/setup/install_prereqs line 76 at r4 (raw file):

    tar -xf drake.tar.gz -C $HOME

    ${maybe_sudo} apt-get update

nit This line is (was) redundant. We already apt-updated on line 56, above.


drake_cmake_installed/setup/install_prereqs line 88 at r4 (raw file):


# Install the source prereqs
${maybe_sudo} ${HOME}/drake/share/drake/setup/install_prereqs

See https://drake.mit.edu/from_source.html#building-with-cmake.

This command has bitrotted (no longer matches our documentation). The correct command is drake/setup/install_prereqs (without sudo).


drake_cmake_external/setup/install_prereqs line 26 at r4 (raw file):


# Install the source prereqs
${maybe_sudo} drake-master/setup/ubuntu/install_prereqs.sh

See https://drake.mit.edu/from_source.html#building-with-cmake.

This command has bitrotted (no longer matches our documentation). The correct command is drake/setup/install_prereqs (without sudo).

Copy link
Contributor

@BetsyMcPhail BetsyMcPhail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 5 unresolved discussions, platform LGTM from [betsymcphail, jwnimmer-tri] (waiting on @jwnimmer-tri and @tyler-yankee)


drake_cmake_external/setup/install_prereqs line 26 at r4 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

See https://drake.mit.edu/from_source.html#building-with-cmake.

This command has bitrotted (no longer matches our documentation). The correct command is drake/setup/install_prereqs (without sudo).

Do the bazel_external and bazel_external_legacy examples need a similar update?

Copy link
Contributor

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 5 unresolved discussions, platform LGTM from [betsymcphail, jwnimmer-tri] (waiting on @BetsyMcPhail and @tyler-yankee)


drake_cmake_external/setup/install_prereqs line 26 at r4 (raw file):

Previously, BetsyMcPhail (Betsy McPhail) wrote…

Do the bazel_external and bazel_external_legacy examples need a similar update?

Our https://drake.mit.edu/from_source.html section for bazel actually just points to the DEE code as the source of truth, so there isn't any defect with things being out of sync.

I'm thinking to just leave alone the bazel side for now, since it already has some TODOs with bazelisk which I'd rather just all solve at the same time.

Copy link
Contributor

@BetsyMcPhail BetsyMcPhail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 5 unresolved discussions, platform LGTM from [betsymcphail, jwnimmer-tri] (waiting on @jwnimmer-tri and @tyler-yankee)


drake_cmake_external/setup/install_prereqs line 26 at r4 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

Our https://drake.mit.edu/from_source.html section for bazel actually just points to the DEE code as the source of truth, so there isn't any defect with things being out of sync.

I'm thinking to just leave alone the bazel side for now, since it already has some TODOs with bazelisk which I'd rather just all solve at the same time.

Sounds good to me.

Copy link
Collaborator Author

@tyler-yankee tyler-yankee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 5 unresolved discussions, platform LGTM from [betsymcphail, jwnimmer-tri] (waiting on @jwnimmer-tri)


drake_cmake_external/setup/install_prereqs line 26 at r4 (raw file):

Previously, BetsyMcPhail (Betsy McPhail) wrote…

Sounds good to me.

Fixed (and verified locally).


drake_cmake_installed/setup/install_prereqs line 41 at r4 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

It seems to me like assigning the empty string should happen prior to the case ... beginning, since we need it to be defined no matter which branch was taken.

Good catch, this is cleaner; fixed.


drake_cmake_installed/setup/install_prereqs line 76 at r4 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

nit This line is (was) redundant. We already apt-updated on line 56, above.

Fixed.


drake_cmake_installed/setup/install_prereqs line 88 at r4 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

See https://drake.mit.edu/from_source.html#building-with-cmake.

This command has bitrotted (no longer matches our documentation). The correct command is drake/setup/install_prereqs (without sudo).

Here, install_prereqs gets the latest nightly release of Drake. From the top-level, drake/setup/install_prereqs doesn't exist, and calling drake/share/drake/setup/install_prereqs requires running as root.

@tyler-yankee
Copy link
Collaborator Author

drake_cmake_external/setup/install_prereqs line 26 at r4 (raw file):

Previously, tyler-yankee wrote…

Fixed (and verified locally).

Leaving the bazel side alone for now means temporarily removing it from the file_sync. Currently, drake_bazel_external/setup/install_prereqs and drake_cmake_external/setup/install_prereqs should be identical.

Copy link
Contributor

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status: 2 unresolved discussions, platform LGTM from [betsymcphail, jwnimmer-tri] (waiting on @BetsyMcPhail and @tyler-yankee)


drake_cmake_external/setup/install_prereqs line 26 at r4 (raw file):

Previously, tyler-yankee wrote…

Leaving the bazel side alone for now means temporarily removing it from the file_sync. Currently, drake_bazel_external/setup/install_prereqs and drake_cmake_external/setup/install_prereqs should be identical.

I'm okay with de-sync. Or, if doing the same change to the bazel side actually succeeds, I'm okay changing bazel, too. (I only wanted to avoid complicated, novel changes on the bazel side.)


drake_cmake_installed/setup/install_prereqs line 88 at r4 (raw file):

Previously, tyler-yankee wrote…

Here, install_prereqs gets the latest nightly release of Drake. From the top-level, drake/setup/install_prereqs doesn't exist, and calling drake/share/drake/setup/install_prereqs requires running as root.

Oops, right, this is cmake_installed not cmake_external. Withdrawn.

@tyler-yankee
Copy link
Collaborator Author

drake_cmake_installed/setup/install_prereqs line 6 at r4 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

BTW Yuck, I guess I missed this file in #361.

I just went back through the history of this file and the only non-relicenseable commit in its ancestry was #181, and I'll say it's been sufficiently rewritten since then that the commit is no longer relevant.

So either in this PR, or in a separate one, please delete this license text and replace with our standard SPDX MIT-0 line.

Fixed.

Copy link
Contributor

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 9 of 9 files at r6, all commit messages.
Reviewable status: :shipit: complete! all discussions resolved, platform LGTM from [betsymcphail, jwnimmer-tri] (waiting on @tyler-yankee)

@tyler-yankee
Copy link
Collaborator Author

drake_cmake_external/setup/install_prereqs line 26 at r4 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

I'm okay with de-sync. Or, if doing the same change to the bazel side actually succeeds, I'm okay changing bazel, too. (I only wanted to avoid complicated, novel changes on the bazel side.)

Changing the bazel script and running bazel test //... works for me locally on both drake_bazel_external and drake_bazel_external_legacy, so I think we should just sync it up now.

Copy link
Contributor

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r7, all commit messages.
Reviewable status: :shipit: complete! all discussions resolved, platform LGTM from [betsymcphail, jwnimmer-tri] (waiting on @tyler-yankee)

Copy link
Contributor

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 unresolved discussion, platform LGTM from [betsymcphail, jwnimmer-tri] (waiting on @tyler-yankee)


a discussion (no related file):
The Jenkins error looks real.

Part of the problem is that the DEE examples that use bazel need to opt-in to installing it now. The new prereqs script has it off by default ...

https://github.com/RobotLocomotion/drake/blob/73c9b1061301b723481c6798ffc5c389aa1c3965/setup/install_prereqs#L31

... so we need --with-bazel in the DEE install_prereqs script (for the bazel_external only, not for the cmake_external).

The problem with cmake_external is actually a latent but in Drake's setup script. The prefetching ...

https://github.com/RobotLocomotion/drake/blob/73c9b1061301b723481c6798ffc5c389aa1c3965/setup/ubuntu/source_distribution/install_prereqs_user_environment.sh#L25-L27

... should be skipped if we're operating in --without-bazel mode.

@tyler-yankee
Copy link
Collaborator Author

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

The Jenkins error looks real.

Part of the problem is that the DEE examples that use bazel need to opt-in to installing it now. The new prereqs script has it off by default ...

https://github.com/RobotLocomotion/drake/blob/73c9b1061301b723481c6798ffc5c389aa1c3965/setup/install_prereqs#L31

... so we need --with-bazel in the DEE install_prereqs script (for the bazel_external only, not for the cmake_external).

The problem with cmake_external is actually a latent but in Drake's setup script. The prefetching ...

https://github.com/RobotLocomotion/drake/blob/73c9b1061301b723481c6798ffc5c389aa1c3965/setup/ubuntu/source_distribution/install_prereqs_user_environment.sh#L25-L27

... should be skipped if we're operating in --without-bazel mode.

Thanks for explaining those. Fixed the bazel examples (hopefully Jenkins is happy), and I can work on fixing the Drake script separately.

Copy link
Contributor

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 10 of 10 files at r8, all commit messages.
Reviewable status: :shipit: complete! all discussions resolved, platform LGTM from [betsymcphail, jwnimmer-tri] (waiting on @tyler-yankee)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants